<%
    if (session.getAttribute("userid") != null) {
        session.invalidate();
        getServletContext().getRequestDispatcher("/MainController?q=index").forward(request, response);
    }
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>AsportoOnline | Registrati</title>

        <script src="http://maps.google.com/maps?file=api&AMP;v=2.55&AMP;key=ABQIAAAA4sriqqpkT4rZot1cK9vguRTEe3oPwTvvxdMV9j-szy2Bac4x0hTS_bXwPwBy0LvCWWXgMNkzvr87gQ" type="text/javascript"></script>

        <script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script> 

        <script type="text/javascript">
            function geolocalizzami() {
                //                document.registra.action = "MainController?q=register_user_action";
                //                document.registra.submit();
                var query = document.getElementById("via").value + ", " + document.getElementById("cap").value + " " + document.getElementById("citta").value;
                
                var coder = new GClientGeocoder();
                coder.getLatLng(query, salva_coord);
            };
            
            function salva_coord(punto){ 
                //alert("Latitudine: "+punto.lat()+" Longitudine: "+punto.lng());
                //document.getElementsByName("coordinate").value = "Latitudine: "+punto.lat()+" Longitudine: "+punto.lng();
                document.getElementById("latitudine").value = punto.lat();
                document.getElementById("longitudine").value = punto.lng();
                
                if(!isNaN(punto.lat()) && !isNaN(punto.lng())) {                
                    document.registra.action = "login.action?q=esegui-reg";
                    //alert("A" + document.getElementById("latitudine").value + " " + document.getElementById("longitudine").value);
                    document.registra.submit();
                }
            };
            
            function stampa() {
                document.getElementById("coordinate").innerHTML = document.getElementById("coord").value;
            };
        </script>

        <style type="text/css">
            @import url("style.css");
        </style>        
    </head>
    <body>
        <div class="meister">
            <div class="page">
                <div class="container">
                    <%@ include file="/WEB-INF/common/header.jsp"%>
                    <div class="navigation"> <a href="index.action?q=index">Home</a> </div>       

                    <div class="center">
                        <h1>Registrati su AsportoOnline AAAA</h1>
                        <p class="error">${error}</p>     

                      <!--  <form name="registra" method="POST" action="javascript:geolocalizzami()"> -->
                      <form name="registra" method="POST" action="login.action?q=esegui-reg">
                            <fieldset><legend><em>Dati anagrafici</em></legend>
                                <label>Nome<br /><input name="nome" value="test"/></label><br />
                                <label>Cognome<br /><input name="cognome" value="test"/></label><br />
                                <label>Data di nascita<br /><input id="datan" name="datan" maxlength="10" value="01/02/1986"/></label><br />
                                <label>Codice Fiscale<br /><input id="cf" name="cf" maxlength="16" value="brbfrc87d13b111x"/></label><br />
                            </fieldset>
                            <fieldset><legend><em>Informazioni di contatto</em></legend>
                                <label>Via<br /><input id="via" name="via" value="strada voglio la pizza"/></label><br />
                                <label>CAP<br /><input id="cap" name="cap" maxlength="5" value="11111"/></label><br />
                                <label>Citt&agrave;<br /><input id="citta" name="citta" value="torino"/></label><br />
                                <input id="latitudine" type="hidden" name="latitudine" value="1.0"/>
                                <input id="longitudine" type="hidden" name="longitudine" value="2.0"/>
                                <label>Telefono<br /><input name="telefono" value="01234567"/></label><br />                
                            </fieldset>
                            <fieldset><legend><em>Dati dell'account</em></legend>                
                                <label>Email<br /><input name="email" value="test@a.com"/></label><br />
                                <label>Conferma email<br /><input name="conferma_email" value="test@a.com"/></label><br />
                                <label>Password<br /><input type="password" name="password" value="test"/></label><br />
                                <label>Conferma password<br /><input type="password" name="conferma_password" value="test"/></label><br />
                                <br />                
                                <label>Tipo di account</label>
                                <div id="radio">
                                    <input type="radio" name="tipo" value="cliente" checked="checked"/> Cliente
                                    <input type="radio" name="tipo" value="venditore" /> Venditore
                                </div>
                                <br />
                                <label>Immagine<input name="urlimmagine" value="default.jpg"/></label>                
                                <br /><br />
                                <input type="submit" value="REGISTRA"/>
                        </form>
                        </fieldset>
                        <br />
                    </div>
                    
                    <%@ include file="/WEB-INF/common/footer.jsp"%>
                </div>
            </div>
        </div>
    </body>
</html>
